local skel = fk.CreateSkill {
  name = "efengqi__cangji",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["efengqi__cangji"] = "藏机",
  [":efengqi__cangji"] = "锁定技，你的初始手牌-2；游戏开始时，你获得一张【八卦阵】与【无中生有】。",

  ["$efengqi__cangji1"] = "哼哼～",
  ["$efengqi__cangji2"] = "哼～",
}

skel:addEffect(fk.GameStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return  player:hasSkill(skel.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local ids = {}
    for _, name in ipairs({"ex_nihilo", "eight_diagram"}) do
      local ret = room:getCardsFromPileByRule(name)[1]
      if not ret then
        local suit, num = Card.Spade, 1
        for cardName, card in pairs(Fk.all_card_types) do
          if cardName == name then
            suit = card.suit
            num = card.number
            break
          end
        end
        ret = room:printCard(name, suit, num).id
        room:setCardMark(Fk:getCardById(ret), MarkEnum.DestructIntoDiscard, 1)
      end
      table.insert(ids, ret)
    end
    room:obtainCard(player, ids, true, fk.ReasonJustMove, player, skel.name)
  end,
})

skel:addEffect(fk.DrawInitialCards, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player
  end,
  on_refresh = function (self, event, target, player, data)
    data.num = math.max(data.num - 2, 0)
  end,
})

return skel
